﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.IO;

namespace TimeRuler
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            DispatcherUnhandledException += App_DispatcherUnhandledException;
        }

        private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
        {
            MessageBox.Show(e.Exception.ToString(),"错误！日志已记录到桌面。检查输入或到项目主页创建issue。建议重启程序避免后续异常。",MessageBoxButton.OK,MessageBoxImage.Error);
            File.AppendAllText(Environment.GetFolderPath(Environment.SpecialFolder.Desktop)+"\\TimeRuler错误日志.txt", e.Exception.ToString());
            e.Handled = true;
        }
    }
}
